import { APlugin } from '../types/common.interface';
import { RenderTrigger } from '../cors/render-trigger';
import { ExecuteRecord } from '../cors/execute-record';
import { Config } from '../cors/config';
import { Inject, Injectable, PluginInjectable } from '../decorators/inject';
import { FreezeCommand } from '../commands/freeze-command';
import { Select } from '../cors/select';

@Injectable()
@PluginInjectable('FreezePlugin')
export class FreezePlugin extends  APlugin {
    constructor(
        protected excuteRecord: ExecuteRecord,
        protected conf: Config,
        protected renderTrigger: RenderTrigger,
        protected select: Select
    ) {
        super();
    }
    public init(): void {
        
    }
    protected createCommand(position: number, type: 'row'|'col') {
        return new FreezeCommand(this.conf, this.renderTrigger, position, type);
    }
    public freezeRow(row: number) {
        let command = this.createCommand(row, 'row');
        this.excuteRecord.execute(command);
    }
    public cancelFreezeRow() {
        let command = this.createCommand(-1, 'row');
        this.excuteRecord.execute(command);
    }
    public freezeCol(col: number) {
        let command = this.createCommand(col, 'row');
        this.excuteRecord.execute(command);
    }
    public cancelFreezeCol() {
        let command = this.createCommand(-1, 'row');
        this.excuteRecord.execute(command);
    }
    public getFreezeInfo() {
        return this.conf.freeze;
    }
    public getSelectInfo() {
        return this.select.selected;
    }
    public destroy(): void {
        
    }
}